const parseUrlParam = (url) => {
  // . 默认匹配除换行符之外的任何单个字符
  const search = /.+\?(.+)$/g.exec(url)[1];
  console.log(search); // user=anonymous&id=123&id=456&city=%E5%8C%97%E4%BA%AC&enabled
  const searchSplit = search.split("&");
  console.log(searchSplit); // [ 'user=anonymous', 'id=123', 'id=456', 'city=%E5%8C%97%E4%BA%AC', 'enabled' ]
  const result = {};
  searchSplit.forEach((item) => {
    if (/=/g.test(item)) {
      const [key, value] = item.split("=");
      result[key] = decodeURIComponent(value);
    } else {
      result[item] = true;
    }
  });
  return result;
};
let url =
  "http://www.domain.com/?user=anonymous&id=123&id=456&city=%E5%8C%97%E4%BA%AC&enabled";
console.log(parseUrlParam(url));
